package com.songlanyun.modules.wechat.controller.api;

import com.songlanyun.common.utils.PageUtils;
import com.songlanyun.common.utils.R;
import com.songlanyun.modules.account.controller.common.AbstractApiController;
import com.songlanyun.modules.wechat.entity.WechatLive;
import com.songlanyun.modules.wechat.service.WechatLiveService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;


@RestController
@RequestMapping("api/wechatLive")
public class WechatLiveApiController extends AbstractApiController {

    @Autowired
    private WechatLiveService wechatLiveService;


    /**
     * 列表
     */
    @RequestMapping("/all")
    public R page(@RequestParam Map<String, Object> params) {
        PageUtils page = wechatLiveService.queryPage4API(params);
        return R.ok().put("page", page);
    }

    @RequestMapping("/getLiveStatus")
    public R getLiveStatus() {
        List<WechatLive> objs = wechatLiveService.queryAll();
        wechatLiveService.synchroWxOlLive();
        return R.ok().put("list", objs);
    }


}

